import { putWithErrorMessage, get } from '@/utils/http/Axios'

//  审批流程
export function setProcessApproval(data) {
    return putWithErrorMessage('/workflow-platform/api/v1/process_instance/task/approve', data)
}
// 我发起的--流程撤销
export function processCancel(data) {
    const { processInstanceId, revokeReason } = data
    return putWithErrorMessage(`/workflow-platform/api/v1/process_instance/revoke/${processInstanceId}`, { revokeReason })
}

// 审批待办的退回接口
export function processInstanceRollback(data) {
    return putWithErrorMessage('/taishan-runtime/api/v5/process/process_instance/rollback', data)
}
// 流程催办
export function setProcessUrge(processInstanceId) {
    return putWithErrorMessage(`/workflow-platform/api/v1/process_instance/urge/${processInstanceId}`)
}

/*
 *  应用端查看流程详情
 */
export function fetchProcessDetail(data) {
    const { processInstanceId, taskId } = data
    return get(`/workflow-platform/api/v1/process_instance/detail/${processInstanceId}/${taskId}`)
}

/*
 *  应用端查看流程提交数据
 */
export function fetchProcessFormState(processInstanceId) {
  return get(`/taishan-runtime/api/v4/page_data/process/${processInstanceId}`)
}

/*
 *  应用端查看流程提交数据
 */
export function changeProcessFormState(data) {
  const { processInstanceId, formData } = data
  return putWithErrorMessage(`/taishan-runtime/api/v4/page_data/process/${processInstanceId}`, formData)
}
